// 此页记录、处理数据
let initState = {
  list: [
    { id: 1, title: "星期一", isFinished: "开心" },
    { id: 2, title: "星期二", isFinished: "不开心" }
  ],
  age:18,
  week:'周一'
}


const reducer = (state = initState, action) => {
  // console.log(state)
  let { type, data } = action
  let key
  if(data){
    key = Object.keys(data)[0]
  }
  switch (type) {
    case "modify":
      state[key] = data[key]
      break;
    case "remove":
      delete state[data]
      break;
    case "replace":
      state = action
      break;
  
    default:
      break;
  }
  // initState = state
  return state
}

export default reducer

